/**
 * Created by yu on 16/8/23.
 */
var fs = require('fs');
var http = require('http');
var server = http.createServer(function(request,response){
    var url = request.url;
    console.log(url);
    if(url==='/'){
        response.setHeader('Content-Type','text/html;charset=utf-8');
        //指定文件路径设置编码,得到的data就是字符串类型的.
        fs.readFile('./index.html','utf-8',function(err,data){
            response.write(data);
            response.end();
        })
    }else if(url==='/style.css'){
        response.setHeader('Content-Type','text/css;');
        //指定文件路径设置编码,得到的data就是字符串类型的.
        fs.readFile('./style.css','utf8',function(err,data){
            response.write(data);
            response.end();
        })
    }else if(url==='/js.js'){
        response.setHeader('Content-Type','text/javascript;');
        //指定文件路径设置编码,得到的data就是字符串类型的.
        fs.readFile('./js.js',function(err,data){
            response.write(data);
            response.end();
        })
    }
})
server.listen('8083','localhost');